%%% License: Creative Commons Attribution Share Alike 4.0 (see https://creativecommons.org/licenses/by-sa/4.0/)
%%% Slides are based heavily on earlier versions of this course taught by Jesper Rudiger.

\documentclass[english,10pt
%,handout
,aspectratio=169
]{beamer}
\input{../FM_preamble.tex}



\title{Financial Markets Microstructure \\ Exercise class 3}

\author{Egor Starkov}

\date{K{\o}benhavns Unversitet \\
	Spring 2020}



\begin{document}
	\AtBeginSection[]{
		\frame<beamer>{
			\frametitle{This lecture:}
			\tableofcontents[currentsection,currentsubsection]
	}}
\frame[plain]{\titlepage}
\addtocounter{framenumber}{-1}



\section{Kyle model}

\begin{frame}{Lecture 5}
	\begin{itemize}
		\item solve exercise 3 in chapter 4 (p.159) which explores competition among speculators
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 4.3}
	\begin{itemize}
		\item Consider a Kyle model with many speculators $i \in \{1,2,...,N\}$.
		\item Every speculator uses a linear strategy
		$$ x_i = \beta (v-\mu) $$
		\item Everything else is same as in lecture
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 4.3.a}
	\begin{exampleblock}{}
		(a) Find the equilibrium aggressiveness $\beta$, determine how it depends on $N$ and explain why.
	\end{exampleblock}
	
	\pause
	
	Speculator $i$ maximizes the expected profit $\mathbb{E} [x_i (v-p)]$.
	
	The clearing price is given by the zero-profit condition:
	\begin{align*}
		p = \mu + \lambda [x_i + (N-1) \beta (v-\mu) + u]
	\end{align*}
	Plugging it into the expected profit expression and maximizing it w.r.t. $x_i$ yields
	\begin{align*}
		x_i &= \underbrace{\frac{1 - \lambda \beta (N-1)}{2 \lambda}}_{=\beta} (v-\mu)
		\\
		\Rightarrow
		\beta &= \frac{1}{\lambda (N+1)}
	\end{align*}
\end{frame}


\begin{frame}{Exercise 4.3.a}
	\begin{align*}
	\beta &= \frac{1}{\lambda (N+1)}
	\end{align*}
	
	\begin{itemize}
		\item $\beta$ decreasing in $N$: the more traders, the smaller is one trader's share (as in Cournot oligopoly)
		\item $N \beta$ increasing in $N$: total order size increases in $N$ because with high $N$, each trader suffers less from higher price (due to lower output)
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 4.3.b}
	\begin{exampleblock}{}
		(b) Derive the price impact coefficient $\lambda$ from the dealer's zero-profit condition
	\end{exampleblock}

	\pause
	
	\begin{align*}
		\lambda = \frac{\mathbb{C}(v,q)}{\mathbb{V}(q)} = \frac{N \beta \sigma^2_v}{(N \beta)^2 \sigma^2_v + \sigma^2_u}	
		% \frac{ \frac{N}{\lambda (N+1)} \sigma^2_v }{ \left( \frac{N}{\lambda (N+1)} \right)^2 \sigma^2_v + \sigma^2_u }
	\end{align*}
	Combining with the expression for $\beta$, we get
	\begin{align*}
		\lambda &= \frac{\sqrt{N}}{N+1} \frac{\sigma_v}{\sigma_u} 
		&
		\beta = \frac{1}{\sqrt{N}} \frac{\sigma_u}{\sigma_v}
	\end{align*}
\end{frame}


\begin{frame}{Exercise 4.3.c}
	\begin{exampleblock}{}
		(c) What is the market depth in equilibrium, and how is it affected by an increase in the number of informed traders, $N$? What is the economic intuition for this result?
		Do you think this result is robust?
	\end{exampleblock}
	
	\pause
	
	\begin{itemize}
		\item Depth is $\frac{1}{\lambda} = \frac{N+1}{\sqrt{N}} \frac{\sigma^2_u}{\sigma^2_v} $
		\item It is increasing in $N$ because traders become more aggressive (relative to their market share) in the presence of competition -- submit larger orders $|x_i|$ given any fixed $v$, -- price reacts less to any fixed order size.
		\item The conclusion is not 100\% robust...
	\end{itemize}
\end{frame}


%\begin{frame}{Exercise 4.3.c}
%	%TODO: rip the pic out of the textbook and elaborate on it
%\end{frame}


\begin{frame}{Exercise 4.3.d}
	\begin{exampleblock}{}
		(d) Compute the ex-ante expected profit of each informed investor. What is the effect of an increase in $N$ on the aggregate profit of informed investors?
	\end{exampleblock}

	\pause
	
	\begin{align*}
		\mathbb{E} [x_i(v-p)] = \frac{\sigma_u \sigma_v}{(N+1) \sqrt{N}}
	\end{align*}
	\begin{itemize}
		\item predictably, the profits of each speculator decrease in $N$
		\item aggregate profit of all speculators $\frac{\sigma_u \sigma_v \sqrt{N}}{N+1}$ also decreases in $N$ (because total aggressiveness $N \beta$ increases away from the monopolistic optimum)
	\end{itemize}
\end{frame}




\section{Limit order book}

\begin{frame}{Lecture 6}
	\begin{itemize}
		\item Solve exercise 1 on pages 232-233 in the textbook. Note that you need to use Bayes' rule to assess the conditional distribution over $v$ given a market order of size $q$
		%\item Solve exercise 5 on page 235 in the textbook on the effect of fees charged for limit orders and market orders
		\item \textcolor{gray}{Suppose that there is no tick; quotes can be placed in a continuous price space. Suppose that there is price priority. What is then the role of time priority, so that first-come quotes at identical prices are served first?} - next Wednesday
		\item If you could choose between trading at discriminatory prices in a limit order book, or to reveal your order size to a dealer, what would influence your choice?
	\end{itemize}
\end{frame}




\subsection{ex 6.1}

\begin{frame}[label=ex1]{Exercise 6.1}
	This exercise considers a two-period model of an LOB.
	\begin{itemize}
		\item \textbf{Security}: Value $v \sim g(v)=\frac{1}{2\sigma} e^{-\frac{|v-\mu|}{\sigma}}$
		\item \textbf{Trader}: 
		\begin{itemize}
			\item Type \textcolor{blue}{$I$}. With prob. $\pi$, knows $v$ and maximizes exp. utility
			\item Type \textcolor{blue}{$N$}. With prob. $1-\pi$, buys/sells (with equal prob.) $x$ shares, with $x \sim f(x)=\frac{1}{2}\theta e^{-\theta |x|}$ 
		\end{itemize}
		\item \textbf{Tick}: Tick size is nil ($\Delta=0$)
	\end{itemize}
	Notice that $\mathbb{E}[v|v \ge z]=z+\sigma$.
\end{frame}


\begin{frame}{Exercise 6.1.a}
	\begin{exampleblock}{}
		(a) Let $Y(A)$ be the cumulative depth up to ask price $A$ in the book and $A^*$ be the lowest ask price in the LOB. Show that when $v \ge A^*$, the optimal strategy of the informed trader is to buy $Y(v)$ shares.
	\end{exampleblock}

	\pause

	\begin{itemize}
		\item Let $P'(q) \equiv \{A: q=Y(A)\}$ be marginal price.
		
		Notice $P'(q) = Y^{-1}(q)$.
		\item The trader's profit from buying $q$ units is $\int_0^q y(v-P'(y)) \, dy.$
		\item Take the FOC wrt. $q$
		\[
		q(v-P'(q))=0 \Leftrightarrow P'(q)=v.
		\]
		\item Denote the optimal strategy by $q^*(v)$ and use the definition of $P'(q)$:
		\[
		P'(q^*)=v \Leftrightarrow Y(P'(q^*))=Y(v) \Leftrightarrow Y(Y^{-1}(q^*))=Y(v) \Leftrightarrow q^*= Y(v).
		\]
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 6.1.b}
	\begin{exampleblock}{}
		(b) Using part (a) and the zero-profit condition show that in eqm:
		\begin{center}
			$
			Y(A)=\frac{1}{\theta} \left[\ln \left(\frac{1-\pi}{\pi}\right) + \ln \left(\frac{A-\mu}{\sigma}\right) + \frac{A-\mu}{\sigma}\right]\text{ if } A>A^*.
			$
		\end{center}
	\end{exampleblock}

	\pause

	\begin{itemize}
		\item Part (a) implies that $v=P'(q^*)$. Zero-profit condition is $P'(q) = \mathbb{E} [v | q^*(v) \geq q]$.
		
		\item Use the latter to write the marginal price:
		\[
			P'(q) = \alpha(q) \mathbb{E}[v|v \ge P'(q)]+(1-\alpha(q))\mathbb{E}[v],
		\]
		where 
		\begin{align*}
			\alpha(q) &\equiv \mathbb{P}(I|\text{buy} \geq q) = \frac{\mathbb{P}(I)\mathbb{P}(\text{buy} \geq q|I) }{\mathbb{P}(\text{buy} \geq q)} 
			\\
			&= \frac{\pi \mathbb{P}(v \ge P'(q))}{\pi \mathbb{P}(v \ge P'(q))+(1-\pi)\mathbb{P}(x \ge q)}
		\end{align*}.
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 6.1.b (2)}
	\begin{itemize}
		\item Compute the ingredients of $\alpha(q)$:
		\begin{align*}
			\mathbb{P}(v \ge P'(q)) 	&=\int_{P'(q)}^\infty g(v) dv = \frac{1}{2} e^{-\frac{P'(q)-\mu}{\sigma}} \\
			\mathbb{P}(x \ge q)	&=\int_q^\infty f(x) dx = \frac{1}{2}e^{-\theta q}
		\end{align*}
		\item Plug them back into $\alpha(q)$:
		\begin{align*}
			\alpha(q)
			& =\frac{\pi \frac{1}{2} e^{-\frac{P'(q)-\mu}{\sigma}}}{\pi \frac{1}{2} e^{-\frac{P'(q)-\mu}{\sigma}} + (1-\pi)\frac{1}{2}e^{-\theta q}} 
			\\
			& = \frac{e^{\theta q-\frac{P'(q)-\mu}{\sigma}}}{e^{\theta q-\frac{P'(q)-\mu }{\sigma}} + \frac{1-\pi}{\pi}} 
		\end{align*}
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 6.1.b (3)}
	\begin{itemize}
		\item Going back to the marginal price, we had
		\begin{align*}
			P'(q) &= \alpha(q) \mathbb{E}[v|v \ge P'(q)]+(1-\alpha(q))\mathbb{E}[v]
		\end{align*}
		\item Recall hint: $\mathbb{E}[v|v \ge P'(q)]=P'(q)+\sigma$. Plug this together with $\alpha(q)$ into the expression above:
		\begin{align*}
			&P'(q) = \alpha(q) (P'(q)+\sigma) + (1-\alpha(q)) \mu 
			\\
			& \Leftrightarrow \frac{1-\pi}{\pi} \cdot \frac{P'(q)-\mu}{\sigma} = e^{\theta q - \frac{P'(q)-\mu}{\sigma}}  \\
			& \Leftrightarrow \ln \left( \frac{1-\pi}{\pi} \right) + \ln \left( \frac{P'(q)-\mu}{\sigma} \right) = \theta q - \frac{P'(q)-\mu}{\sigma} 
		\end{align*}
		Finally, substitute $Y(A)=q(A)$ and $A=P'(q)$ and re-arrange to get result.
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 6.1.c}
	\begin{exampleblock}{}
		(c) Show that the book becomes thinner on the ask side when (i) $\pi$ increases or (ii) $\sigma$ increases. What is the economic intuition for this result.
	\end{exampleblock}

	\pause

	$$
		Y(A)=\frac{1}{\theta} \left[\ln \left(\frac{1-\pi}{\pi}\right) + \ln \left(\frac{A-\mu}{\sigma}\right) + \frac{A-\mu}{\sigma}\right]\text{ if } A>A^*.
	$$
	\begin{itemize}
		\item \textbf{Informed trading}. 
		\[
		\frac{\partial Y(A)}{\partial \pi} = \frac{1}{\theta}\left[ -\frac{\pi}{1-\pi}\cdot \frac{1}{\pi^2}\right]=\frac{1}{\theta}\left[ -\frac{1}{\pi(1-\pi)}\right]<0
		\]
		More informed trading implies greater risk when posting orders
	\end{itemize}
\end{frame}


\begin{frame}{Exercise 6.1.c}
	\begin{exampleblock}{}
		(c) Show that the book becomes thinner on the ask side when (i) $\pi$ increases or (ii) $\sigma$ increases. What is the economic intuition for this result.
	\end{exampleblock}

	$$
		Y(A)=\frac{1}{\theta} \left[\ln \left(\frac{1-\pi}{\pi}\right) + \ln \left(\frac{A-\mu}{\sigma}\right) + \frac{A-\mu}{\sigma}\right]\text{ if } A>A^*.
	$$
	
	\begin{itemize}
		\item \textbf{Value uncertainty}. 
		\[
		\frac{\partial Y(A)}{\partial \sigma} = \frac{1}{\theta} \left[ -\frac{\sigma}{A-\mu}\frac{A-\mu}{\sigma^2} - \frac{A-\mu}{\sigma^2}\right]=\frac{1}{\theta} \left[ -\frac{1}{\sigma} - \frac{A-\mu}{\sigma^2}\right]<0
		\]
		More value uncertainty implies greater risk when posting orders
	\end{itemize}
\end{frame}



%\subsection{ex 6.5}
%
%\begin{frame}[label=ex5]{Exercise 6.5}
%	\begin{itemize}
%		\item Consider the LOB model of section 6.4.1 with $\sigma=0$ and $\tau=1$
%		\item Thus, there is no fundamental value uncertainty, and the asset is `infinitely lived'
%		\item Prior on fundamental value is $\mu_0$
%		\item The agents have private value $y \in \{-L,L\}$ with equal probability
%		\item Suppose limit orders last one period
%		\item Let $f_{mo}$ be the fee per share for market orders, and $f_{lo}$ the fee per share for limit orders (when the order executes). Let $f=f_{mo}+f_{lo}$
%		\item Tension: either trade now with market order, or post limit order and hope that it is hit by next trader
%		\item Look for stationary equilibrium: prices $A$ and $B$ are the same each period
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Exercise 6.5.a}
%	\textbf{Part (a)}. Compute bid and ask quotes in equilibrium
%	\smallskip
%	\smallskip
%	\begin{itemize}
%		\item Use the approach in chapter 6.4.2. Set prices such that limit orders are always executed if the next trader has the right type.
%		\item Suppose we set a price $A$ such that next trader will use a buy market order if he is type $L$. Given $B$, the highest $A$ that will satisfy this is
%		\begin{equation}\label{eq1}
%		\frac{1}{2}[\mu_0+L-B-f_{lo}]=\mu_0+L-A-f_{mo}.
%		\end{equation}
%		\item Similarly, given $A$, the lowest $B$ such that next trader will use a sell market order if he is type $-L$ is
%		\begin{equation} \label{eq2}
%		B-(\mu_0-L)-f_{mo}=\frac{1}{2}[A-(\mu_0-L)-f_{lo}]
%		\end{equation}
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Exercise 6.5.a (2)}
%	\begin{itemize}
%		\item Add 2 times \eqref{eq1} to \eqref{eq2} to get
%		\begin{align*}
%		A=\mu_0+\frac{L}{3}+\frac{f_{lo}-2f_{mo}}{3}\\
%		B=\mu_0-\frac{L}{3}-\frac{f_{lo}-2f_{mo}}{3}
%		\end{align*}
%		\item This gives a spread of
%		\[
%		S=\frac{2L}{3}+2\frac{f_{lo}-2f_{mo}}{3}.
%		\]
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Exercise 6.5.b}
%	\textbf{Part (b)}. Show that the bid-ask spread decreases in $f_{mo}$ and increases in $f_{lo}$
%	\smallskip
%	\smallskip
%	\begin{itemize}
%		\item Recall spread
%		\[
%		S=\frac{2L}{3}+2\frac{f_{lo}-2f_{mo}}{3}.
%		\]
%		\item Increasing in $f_{lo}$: when it is less attractive to post limit orders, bid (ask) price must be lower (higher) to attract limit order posters
%		\item Decreasing in $f_{mo}$: when it is less attractive to post market orders, bid (ask) price must be higher (lower) to attract market order posters
%	\end{itemize}
%\end{frame}
%
%
%\begin{frame}{Exercise 6.5.c}
%	\textbf{Part (c)}. Trading platforms often subsidize traders who submit limit orders. That is, they set $f_{lo}<0$ and $f_{mo}>0$, maintaining that this practice ultimately helps to narrow the spread and benefits traders submitting market orders. Holding the total trading fee fixed, is this argument correct?
%	\smallskip
%	\smallskip
%	\begin{itemize}
%		\item Suppose $f=f_{lo}+f_{mo}$. Then we can rewrite spread as
%		\[
%		S=\frac{2L}{3}-\frac{2f}{3}+2f_{lo}.
%		\]
%		\item This is increasing in $f_{lo}$, so setting $f_{lo}<0$ would be optimal
%	\end{itemize}
%\end{frame}
%
%
%\subsection{continuous tick}
%
%\begin{frame}{Tick size and time priority}
%	\begin{exampleblock}{}
%		Suppose that there is no tick; quotes can  be placed in a continuous price space. Suppose that there is price priority. What is then the role of time priority, so that first-come quotes at identical prices are served first?
%	\end{exampleblock}
%	
%	\centering
%	\emph{``...The size of the trading increment is a
%	powerful level that is underappreciated by
%	regulators. The \alert{finer the trading increment},
%	\structure{the more important price priority becomes
%	relative to time priority}. In other words, if the
%	market was designed to trade at continuous
%	(vs discrete) non‐penny increments you could
%	always win a trade by quoting the best price
%	and the \structure{speed game would be non existent}''}
%	
%	\begin{flushright}
%		--Narang, Manoj ``HFT 101 with Tradeworx'',
%		May 20, 2014
%	\end{flushright}
%\end{frame}
%
%
%\begin{frame}{Tick size and time priority}
%	\begin{itemize}
%		\item The role of the tick is essentially \textit{to balance price priority and time priority}
%		\item Larger tick gives more time priority, smaller tick gives more price priority
%		\item When there is no tick, there is essentially no time priority...
%		\item However, there is some evidence that ticks may arise \textit{endogenously}. In that case, time priority takes importance again
%	\end{itemize}
%\end{frame}



\subsection{choice: LOB or trade size} 

\begin{frame}{Choosing between LOB and revealing order size}
	\begin{exampleblock}{}
		If you could choose between trading at discriminatory prices in a limit order book, or to reveal your order size to a dealer, what would influence your choice?
	\end{exampleblock}
	\begin{itemize}
		\item Recall the basic tensions between the two frameworks: 
		\begin{itemize}
			\item When order size revealed, can trade all units at single (low-moderate) price
			\item When trading in the limit book, marginal price is higher, but not the prices paid on the first units
		\end{itemize}
		\item Thus, the answer will depend on (i) the size of your order relative to the degree of uncertainty in the market and (ii) where it is located with respect to the ticks
	\end{itemize}
\end{frame}





\end{document} 